package edu.ptit.app;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import edu.ptit.jad.configuration.CONSTANTS;
import edu.ptit.jad.data.MatrixUtils;
import edu.ptit.jad.similarity.CosineSimilarityMeasure;

public class AppLDA {

	public static void main(String[] args) throws Exception {

		//process("data/input/news_at.theta","data/input/ads_at.theta","data/output/at_lda.simi.jad");
		process("data/input/news_only_ad.theta","data/input/ads_only_ad.theta","data/output/lda_only_ad.simi.jad");
		//process("data/input/news_at_cats.theta","data/input/ads_at_cats.theta","data/output/at_cats_lda.simi.jad");
		
	}

	public static void process(String filenews, String fileads, String saveFile)
			throws Exception {

		double[][] news = MatrixUtils.readMatrix(filenews);
		double[][] ads = MatrixUtils.readMatrix(fileads);

		int nRows = news.length;
		int nCols = ads.length;

		double[][] simMatrix = new double[nRows][nCols];

		CosineSimilarityMeasure measure = new CosineSimilarityMeasure();
		for (int i = 0; i < nRows; i++) {

			for (int j = 0; j < nCols; j++) {

				simMatrix[i][j] = measure.calculate(news[i], ads[j]);

			}

		}

		MatrixUtils.saveMatrix(simMatrix, saveFile);

	}

}
